# the minimum version of CMake.
cmake_minimum_required(VERSION 3.5.0)
project(ndk)

set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
# Temporarily commented out due to missing sentry-native directory
# set(SENTRY_NATIVE_SRC ${CMAKE_SOURCE_DIR}/../../../../../sentry-native)
# flutter/ohos/src/main/cpp/CMakeLists.txt
# flutter/sentry-native
# if (NOT THIRDPARTY_DIR)
#     set(THIRDPARTY_DIR "${SENTRY_NATIVE_SRC}/external/external/third_party")
# endif()

# Adding sentry-native project
# add_subdirectory(${SENTRY_NATIVE_SRC} sentry_build)

if(DEFINED PACKAGE_FIND_FILE)
    include(${PACKAGE_FIND_FILE})
endif()

include_directories(${NATIVERENDER_ROOT_PATH}
        ${NATIVERENDER_ROOT_PATH}/include)

add_library(entry SHARED ndk_sample.cpp)
# Temporarily commented out sentry::sentry link due to missing sentry-native
target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so)
# target_link_libraries(entry PUBLIC libace_napi.z.so $<BUILD_INTERFACE:sentry::sentry>)

# Build ReplayEncoder native module (libreplay_encoder.z.so)
set(SENTRY_REPLAY_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../ohos/src/lib/sentry_ohos/src/main/cpp/replay_encoder)
set(SENTRY_REPLAY_SOURCES
    ${SENTRY_REPLAY_SRC_DIR}/ReplayEncoder.cpp
    ${SENTRY_REPLAY_SRC_DIR}/NapiBridge.cpp
)

add_library(replay_encoder SHARED ${SENTRY_REPLAY_SOURCES})
target_include_directories(replay_encoder PRIVATE ${SENTRY_REPLAY_SRC_DIR})
target_link_libraries(replay_encoder PUBLIC
    libace_napi.z.so
    libhilog_ndk.z.so
    libnative_media_codecbase.so
    libnative_media_core.so
    libnative_media_venc.so
    libnative_media_avmuxer.so
    libnative_media_avsource.so
    libnative_media_avdemuxer.so
    libnative_image.so
    libnative_window.so
    libnative_buffer.so
)
